/*
*
==============================================================================
*  Name        : IOmenOctree.h
*  Part of     : Omen Game Engine
*  Description : Inteface classes IOctreeNode and IOctree
*  Version     : 1.0
*
*  Copyright (c) 2013 Lauri Kortevaara.
* 
==============================================================================
*/

#pragma once

#include "OmenConfig.h"
#include "OmenMath.h"
#include "IOmenObject.h"
#include "IOmenMesh.h"

namespace Omen
{
    /// <summary>IOctreeNode represents one node in the Octree</summary>
    class OMEN_API IOctreeNode : public Omen::IObject
    {
    public:
        virtual Omen_GUID classId() const = 0;                              /// <summary>inherited from Omen::IObject, returns the class id of IOctreeNode implementing class</summary>

        virtual Omen::AABB& boundingBox() = 0;                              /// <summary>Returns reference to bounding box of this node</summary>
        virtual void setBoundingBox( const Omen::AABB& boundingBox ) = 0;   /// <summary>Sets the bounding box of this node</summary>
            
        virtual IOctreeNode** children() = 0;                               /// <summary>Returns pointer to the 8 child nodes</summary>
        virtual bool leaf() const = 0;                                      /// <summary>Returns true if this node is a leaf node</summary>
        
        virtual void addFace( Omen::IMesh::Face* pFace ) = 0;               /// <summary>Add face to the node</summary>
        virtual unsigned long faceCount() = 0;                              /// <summary>In case this is a leaf node, return the number of faces contained in this node</summary>
        virtual void getFaces( Omen::IMesh::Face** pListFaces, unsigned long maxSize ) = 0; /// <summary>Get the faces contained in this node</summary>

        virtual unsigned int depth() const = 0;                             /// <summary>Returns how deep in the hierarchy this node is</summary>

    protected:
    private:
    };

    class OMEN_API IOctree : public Omen::IObject
    {
    public:
        virtual Omen_GUID classId() const = 0;  //
  
        virtual IOctreeNode*    rootNode() const = 0;                       /// <summary>Returns root node of the octree</summary>
        virtual void setRootNode( IOctreeNode* pRootNode ) = 0;             /// <summary>Assigns the root node of this octree</summary>

        virtual unsigned int maxDepth() const = 0;                          /// <summary>Returns the maximum depth set for this octree</summary>
        virtual unsigned int minimumFaceCount() const = 0;               /// <summary>Returns the minimum element count (object,mesh,face) that is used to stop the creation the octree in depth</summary>
    protected:
    private:
    };

    /// <summary>Octree creation function, called from the IOmenFactory::createOctree </summary>
}